// 引入css
require("../css/sports-data.less")

// 登录拦截
window.$check.checkLogin();

const BASE_URL = 'http://139.9.177.51:8099' // 接口请求的 URL
// 入口函数
document.ready(function () {
    let id = window.location.search.split("=")[1]
    console.log(id);

    const backBtn = document.querySelector("#back");
    backBtn.addEventListener("click", function () {
        history.back();
    })

    const startBtn = document.querySelector(".start");
    const curTitle = document.querySelector("#cur_title");
    const min = document.querySelector("#min");
    const heat = document.querySelector("#heat");
    const intro = document.querySelector(".intro");
    const videoBox = document.querySelector(".video-box")
    window.$http.get("/sports/courseDetail?id=" + id, function (res) {
        startBtn.addEventListener("click", function () {
            window.localStorage.setItem("videos", JSON.stringify(res.data.fragments))
            window.localStorage.setItem("id", JSON.stringify(res.data.courseId))
        })
        console.log(res);
        videoBox.style = "background-image:url(${BASE_URL + latest.imgurl"
        videoBox.style.backgroundImage = `url(${BASE_URL + res.data.imgurl})`
        curTitle.textContent = res.data.name;
        min.textContent = res.data.time;
        heat.textContent = res.data.calorie;
        intro.textContent = res.data.desc + "...";

    })

})
